package cn.cmvideo.springboot;

import java.util.concurrent.Semaphore;

public class SemaphoreCase
{
	private static Semaphore s = new Semaphore(10);
	
	public static void main(String[] args)
	{
		for(int i = 0; i < 30; i++)
		{
			new Thread(new Runnable()
			{
				
				@Override
				public void run()
				{
					try
					{
						s.acquire();
						
						System.out.println(Thread.currentThread().getName());
						
						s.release();
						
					} catch (InterruptedException e)
					{
						e.printStackTrace();
					}
					
				}
			}).start();
		}
	}

}
